package com.ylr.base.common.utils;

import org.jetbrains.annotations.NotNull;
import org.springframework.context.EmbeddedValueResolverAware;
import org.springframework.util.StringValueResolver;

/**
 * Created by IntelliJ IDEA.
 *
 * @author wei
 * date: 2023-05-01 22:18:47
 * className: PropertiesUtil 配置文件值获取工具类
 * version: 1.0
 * description:
 */
public class PropertiesUtils implements EmbeddedValueResolverAware {
    private StringValueResolver stringValueResolver;

    @Override
    public void setEmbeddedValueResolver(@NotNull StringValueResolver resolver) {
        stringValueResolver = resolver;
    }

    /**
     * 根据key获取配置文件值
     * @param name key名称
     * @return 值
     */
    public String getPropertiesValue(String name){
        return stringValueResolver.resolveStringValue(name);
    }
 
}